package data.nanjing.expo.models.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import data.nanjing.expo.common.DateTimeUtil;
import data.nanjing.expo.common.Util;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * Created by zjp on 2018/6/12.
 *
 * 发布的活动信息表
 * 对应数据表:trade_activity_info
 */
public class ActivityInfo {

    public ActivityInfo() {}

    public ActivityInfo(String activityType, String activityContent, String activityName, String province, String city,
                        String area, String industry, String isFree, String imagePath, Integer allowNum, Date startTime,
                        Date endTime) {
        this.activityType = activityType;
        this.activityContent = activityContent;
        this.activityName = activityName;
        this.province = province;
        this.city = city;
        this.area = area;
        this.industry = industry;
        this.isFree = isFree;
        this.imagePath = imagePath;
        this.allowNum = allowNum;
        this.startTime = startTime;
        this.endTime = endTime;
    }

    private Integer id;

    private Integer userId; //发布者id

    private String activityType;    //活动类型:online,offline

    @NotNull(message = "活动内容不能为空")
    private String activityContent; //活动内容

    @NotNull(message = "活动名称不能为空")
    private String activityName;    //活动名称

    @NotNull(message = "省份名不能为空")
    private String province;    //省

    @NotNull(message = "城市名不能为空")
    private String city;    //市

    @NotNull(message = "区名不能为空")
    private String area;    //区

    @NotNull(message = "至少选择一个行业")
    private String industry;    //行业

    private String refuseReason;    //违规原因

    private Integer status;     //活动状态，默认为normal，违规设置为refuse,取消为cancel

    private String isFree; //是否免费

    @NotNull(message = "必须上传图片")
    private String imagePath;   //图片路径

    @Min(value = 1, message = "至少1人可参加")
    @NotNull(message = "可参加人数不能为空")
    private Integer allowNum;    //限定活动人数

    private Integer applyNumber;    //报名人数

    private Integer favoriteNumber; //收藏人数

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @NotNull(message = "活动开始时间不能为空")
    private Date startTime; //活动开始时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @NotNull(message = "活动结束时间不能为空")
    private Date endTime;   //活动结束时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date updateTime;

    private String finalPath;   //图片真实路径

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getActivityType() {
        return activityType;
    }

    public void setActivityType(String activityType) {
        this.activityType = activityType;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getActivityContent() {
        return activityContent;
    }

    public void setActivityContent(String activityContent) {
        this.activityContent = activityContent;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getIndustry() {
        return industry;
    }

    public void setIndustry(String industry) {
        this.industry = industry;
    }

    public String getRefuseReason() {
        return refuseReason;
    }

    public void setRefuseReason(String refuseReason) {
        this.refuseReason = refuseReason;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getIsFree() {
        return isFree;
    }

    public void setIsFree(String isFree) {
        this.isFree = isFree;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public Integer getAllowNum() {
        return allowNum;
    }

    public Integer getApplyNumber() {
        return applyNumber;
    }

    public void setApplyNumber(Integer applyNumber) {
        this.applyNumber = applyNumber;
    }

    public Integer getFavoriteNumber() {
        return favoriteNumber;
    }

    public void setFavoriteNumber(Integer favoriteNumber) {
        this.favoriteNumber = favoriteNumber;
    }

    public void setAllowNum(Integer allowNum) {
        this.allowNum = allowNum;
    }

    public String getStartTime() {
       return DateTimeUtil.dateFormat(startTime, DateTimeUtil.MINUTE_PATTERN);
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return DateTimeUtil.dateFormat(endTime, DateTimeUtil.MINUTE_PATTERN);
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getCreateTime() {
        return DateTimeUtil.dateFormat(createTime, DateTimeUtil.MINUTE_PATTERN);
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return DateTimeUtil.dateFormat(updateTime, DateTimeUtil.MINUTE_PATTERN);
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getFinalPath() {
       return Util.getFinalFilePath(imagePath, "480", "293");
    }

    @Override
    public String toString() {
        return "ActivityInfo{" +
                "id=" + id +
                ", userId=" + userId +
                ", activityContent='" + activityContent + '\'' +
                ", activityName='" + activityName + '\'' +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", area='" + area + '\'' +
                ", industry='" + industry + '\'' +
                ", refuseReason='" + refuseReason + '\'' +
                ", status=" + status +
                ", isFree='" + isFree + '\'' +
                ", imagePath='" + imagePath + '\'' +
                ", allowNum=" + allowNum +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
